<template>
  <div class="box">
    <RenderTable 
      :superQueryFieldList="superQueryFieldList" 
      :queryParamArr = "queryParamArr"
      :defColumns="defColumns"
      :url = "url"
      @handleEdit = "handleEdit"
      ref='renderTable'
    >
    
      <div slot="btn">
        <p-button type="primary" @click="showAddModal">新增</p-button>
      </div>

      <template v-slot:action='{record}'>
        <p-popconfirm
          title="确定删除吗?"
          @confirm="() => $refs.renderTable.handleDelete(record.id)"
        >
          <a>删除</a>
        </p-popconfirm>
      </template>

    </RenderTable>

    <UnstandardDelareTypeModal ref='unstandardDelareTypeModal' @handleSuccess = 'handleSuccess'></UnstandardDelareTypeModal>

  </div>
</template>

<script type="text/javascript">
import RenderTable from '@/components/renderTable'
import UnstandardDelareTypeModal from './modules/unstandardDelareTypeModal.vue'

const superQueryFieldList =
[
  {
    value: "errorReasonBig",
    text: "故障原因大类",
    type: "String",
  },  
  {
    value: "unstandardWtcode",
    text: "非标工时代码",
    type: "String",
  },
]
export default {
  data() {
    return {
      superQueryFieldList,
      queryParamArr: [
        {
          label: "异常类别",
          placeholder: "请输入异常类别",
          type: 'input',
          key: 'exceptionType',
          value: ''
        }
      ],
      defColumns: [
        {
          title: "序号",
          dataIndex: "",
          key: "rowIndex",
          width: 60,
          align: "center",
          customRender: (t, r, index) => {
            return parseInt(index) + 1;
          },
        },

        {
          title: "异常类别",
          align: "center",
          dataIndex: "exceptionType",
        },
        {
          title: "故障原因大类",
          align: "center",
          dataIndex: "errorReasonBig",
        },
        {
          title: "非标工时代码",
          align: "center",
          dataIndex: "unstandardWtcode",
        },

        {
          title: "操作",
          dataIndex: "action",
          align: "center",
          scopedSlots: { customRender: "action" },
        },
      ],
      url: {
        list: '/mes-manpower/mesHrUnstandardWorktime/list',
        delete: '/mes-manpower/mesHrUnstandardWorktime',
      },
    
      layout: {
        labelCol: { span: 4 },
        wrapperCol: { span: 14 },
      },         
    }
  },
  mounted() {
  },
  methods: {
    handleEdit(record){
      this.$refs.unstandardDelareTypeModal.showModal(record)
    },
    // 显示新增弹窗
    showAddModal(){
      this.$refs.unstandardDelareTypeModal.showModal()
    },
    handleSuccess(){
      this.$refs.renderTable.loadData()
    }
  },
  components: {
    RenderTable,
    UnstandardDelareTypeModal
  }
}
</script>

<style lang="less" scoped>
</style>

